import java.io.*;

class IncrementalIntPrint extends Thread {
    static final private int STEP = 1;
    public volatile boolean stop = false;
    
    static public void main(String args[]) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        IncrementalIntPrint test = new IncrementalIntPrint();
        System.out.println("Start printing incremental integer:");
        test.start();
        stdin.readLine();
        System.out.println("Try to stop the printing thread...");
        test.stop = true;
    }

    public void run() {
        int integerNow = 1;
        while (!stop) {
            System.out.println(integerNow);
            integerNow += STEP;
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
            }
        }
        System.out.println("Printing stopped.");
    }
}
